<template>
  <div>
    <div class="table-operator" v-if="stage !== '05010' && stage !== '05050'">
      <a-button :disabled="status == '9' || status == '2' || status == '3'"
                v-permission="['30010']"
                type="primary"
                @click="showConfirm">
        提交审核
      </a-button>
      <a-button :disabled="status !== '2'"
                v-permission="['30020']"
                @click="setApproveReason('9')">
        同意
      </a-button>
      <a-button :disabled="status !== '2'"
                v-permission="['30020']"
                type="danger"
                style="margin-top: 10px"
                @click="setApproveReason('1')">
        拒绝
      </a-button>
    </div>
    <a-table
      ref="table"
      size="middle"
      bordered
      class="table_header_blue"
      rowKey="id"
      :columns="columns"
      :dataSource="dataSource"
      :pagination="false"
      :loading="loading"
    >
      <span slot="actionName">
        <a-upload v-if="stage !== '05010' && stage !== '05050'"
                  :disabled="status == '9' || status == '2' || status == '3'"
                  v-permission="['30010']" :data="fileData" name="files" :showUploadList="false" :multiple="false"
                  :headers="tokenHeader" accept=".docx, .doc, .xlsx, .xls, .pdf, .jpeg, .png"
                  :action="url.upLoad" @change="handleImportExcel">
          <a-button
            size="small"
            type="primary"
            icon="import">上传</a-button>
        </a-upload>
        <span v-else>操作</span>
      </span>
      <span slot="action" slot-scope="text, record">
        <a @click="OnPerview(record)">预览</a>
        <a-divider type="vertical"/>
        <a @click="OnDownLoad(record)">下载</a>
      </span>
    </a-table>
    <SelectApprove ref='approver' :id='id' @submitData='handleSubmit'></SelectApprove>
    <SetReason ref='setReason' @approveReason='approveData'></SetReason>
  </div>
</template>

<script>
  import {filePerviewMixin} from '@/mixins/filePerviewMixin'
  import {JeecgListMixin} from '@/mixins/JeecgListMixin'
  import {butStatus} from '../public/butStatus'
  import SelectApprove from '../public/SelectApprover'
  import SetReason from "../public/SetReason"
  import columns from './indexColumns'

  export default {
    name: "bgxdb",
    mixins: [JeecgListMixin, filePerviewMixin, butStatus],
    components: {
      SelectApprove,
      SetReason
    },
    props: ['id', 'type', 'stage'],
    data() {
      return {
        queryParam: {
          id: this.id,
          typeId: this.type,
        },
        fileData: {
          biz: 'baogao_xdb',
          type: 'baogao_xdb',
          proId: this.id
        },
        typeId: this.type,
        bgType: 'baogao_xdb',
        statusKey: 'xdb',
        //表头
        columns: columns(this),
        url: {
          list: '/sjxmzygl/sjWorkBaogao/queryAuditReportInfo',
          submit: '/sjxmzygl/sjWorkUsers/submitAudit',
          approve: '/sjxmzygl/sjWorkUsers/zyApplyCommit',
          saveBg: '/sjxmzygl/sjWorkBaogao/saveBg',
          upLoad: `${window._CONFIG['domianURL']}/sys/common/sjBgUpload`
        }
      }
    },
    created() {
    },
    methods: {}
  }
</script>

<style lang="less" scoped>
@import '~@assets/less/tableTheme.less';
  .funBtn {
    padding: 0 10px;
    margin-left: 10px;
  }
</style>